package demo1;
import java.lang.reflect.Array;
class MyArray<T> {
//    public T[] obj2 = new T[10]; error
    public T[] obj = (T[])new Object[10];

    public void setVal(int pos,T val) {
        obj[pos] = val;
    }

    public T getPos(int pos) {
        return obj[pos];
    }
    public T[] getObj2() {
        return obj;
    }
}

public class Test {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setVal(0,10);
        myArray.setVal(1,2);
        myArray.setVal(2,6);
        int a  =  myArray.getPos(1);
        MyArray<String> myArray2 = new MyArray<String>();
        myArray2.setVal(0,"hello");
        myArray2.setVal(1,"hello2");
        String str = myArray2.getPos(0);
    }

}
